<template>
<div>
  <el-dialog
    title="列表详情"
    :visible.sync="dialogVisible"
    center
    width="50%"
    :before-close="handleClose">
    <el-card v-loading="loading">
      <el-form :model="detailOne" ref="form"  label-width="100px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="设备名称:">
              <span>{{detailOne.fname}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="设备编码:">
              <span>{{detailOne.fnumber}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="简称:">
              <span>{{detailOne.fsimplename}}</span>
            </el-form-item>
          </el-col>
        </el-row>
      <el-row>
      <el-col :span="8">
        <el-form-item label="规格型号" prop="fmodel">
          <span>{{detailOne.fmodel}}</span>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="出厂日期" prop="foutdate" :disabled="isView">
          <el-date-picker
            v-model="detailOne.foutdate"
            type="date"
            style="width: 100%;"
            format="yyyy-MM-dd HH:mm:ss"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="验收日期" prop="fcheckindate" :disabled="isView">
          <el-date-picker
            v-model="detailOne.fcheckindate"
            type="date"
            style="width: 100%;"
            format="yyyy-MM-dd HH:mm:ss"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
      </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="功率" >
            <span>{{detailOne.fpower}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="设备分类" prop="ftype" :disabled="isView">
            <el-select  class="fullWidth" v-model="detailOne.ftype" filterable placeholder="请选择" >
              <el-option v-for="item in equipment.groupData" :key="item.value" :label="item.label"
                         :value="item.value+''">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="使用地点" prop="fuseraddress" :disabled="isView">
            <el-input v-model="detailOne.fuseraddress"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="主设备" :disabled="isView">
            <el-radio-group v-model="detailOne.fismain" >
              <el-radio :label="0">是</el-radio>
              <el-radio :label="1">否</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="采集数据" prop="fcollectdata" disabled>
            <el-radio-group v-model="detailOne.fcollectdata">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="0">否</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="关键设备" prop="fiskey">
            <el-radio-group v-model="detailOne.fiskey">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="0">否</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="关联主设备:" >

            <span>{{detailOne.fmainequipmentname}}</span>

          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="技术水平:" prop="flevel">
<!--            <tie-enum v-if="isLoading" v-model="equipment.flevel" className="cn.hxlc.tie.demo.core.enums.LevelEnum"
                      :status="status"></tie-enum>-->
            <template slot-scope="scope">
              <el-tag v-if="value ==0 " type="success">领先水平</el-tag>
              <el-tag v-if="value ==1 " type="success">先进水平</el-tag>
              <el-tag v-if="value ==2 " type="success">一般水平</el-tag>
              <el-tag v-if="value ==3 " type="success">落后水平</el-tag>
            </template>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="运行状态:" prop="frunstate" >
            <template slot-scope="scope">
              <el-tag v-if="value ==0 " type="success">正常使用</el-tag>
              <el-tag v-if="value ==1 " type="success">待修</el-tag>
              <el-tag v-if="value ==2 " type="success">检修</el-tag>
              <el-tag v-if="value ==3 " type="success">保养</el-tag>
              <el-tag v-if="value ==4 "  type="success">封存</el-tag>
              <el-tag v-if="value ==5 " type="success">报废</el-tag>
            </template>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="吨位:"  >
           <span>{{detailOne.ftonnage}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="车间名称:"  >
            <span>{{detailOne.fdeptname}}</span>
<!--      <el-select  class="fullWith"  v-model="detailOne.ffactoryid" filterable placeholder="请选择">
              <el-option
                v-for="item in equipment.deptNames"
                :key="item.value"
                :label="item.label"
                :value="item.value+''">
              </el-option>
            </el-select>-->
          </el-form-item>
          </el-col>
        <el-col :span="8">
          <el-form-item label="物料名称:" prop="fmaterialname">
           <span>{{detailOne.fmaterialname}}</span>
          </el-form-item>
        </el-col>
      </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="fremark">
              <el-input v-model="detailOne.fremark"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
    </el-form>
    </el-card>

      <span slot="footer" class="dialog-footer">
        <el-button type="plain" @click="handleClose">关 闭</el-button>
<!--        <el-button @click="edit">保存</el-button>-->
      </span>

  </el-dialog>
</div>
</template>

<script>
import Psy from "@/api/psyManage/Psy";
import Group from "@/api/psyManage/Group";

export default {
  name: "detail_equipment",
   props:{
     status: { type: String },
     width: { type: String, default: '60vw' },
     fgroupid: { type: '' },
     fid:{
       type:Number,
     },
   },
  data(){
    return{
      detailOne:{},
      dialogVisible:true,
      loading:'',
      isLoading:'',
      value:'',
     groupTreeData:[],
      equipment:{},
      detail:{},
      isView:true,
     // fdeptname:null,
      //fmaterialname: null,
    };
  },
  async created() {
    /*this.isLoading=true
    let api=new Psy();
   this.detailOne=await api.queryListPage({})
    this.isLoading=false;*/

    await this.init();
    await this.getEquipment();
    await this.getWorkshopName();
  },
  methods:{
    handleClose(){
      this.$emit("close",{name:"detail",isRefresh:true})
    },
    getFactory(){
      this.loading=true;
      let https=new Psy()



    },
   async init() {
     this.loading = true;
     let https=new Psy()
     https.detail({fid:this.fid}).then(res => {
       console.log(res)
       this.detailOne=res.data
       this.detailOne.ftype=this.detail.ftype
       this.loading = false;
     }).catch(e => this.loading = false)
     console.log(this.detailOne)
   },

    async getEquipment() {
      this.isLoading = true;
      let group = new Group()
      let groupTreeData = await group.queryGroupTree()
      const res = groupTreeData.data
      this.equipment.groupData = res.map(function (i) {
        return {label: i.nodeName, value: i.nodeId}
      })
      this.isLoading=false;
    },
    async getWorkshopName() {
      this.isLoading = true;
      let grop = new Group()
      let manufactory = await grop.getWorkList()
      const r = manufactory.data
      const deptNames = r.map(i => {
        return {label: i.deptName, value: i.deptId}
      })
      this.equipment.deptNames = deptNames;
      console.log(this.equipment.deptNames)
      this.isLoading = false
    },


  }
}
</script>

<style scoped>

</style>
